package com.sz.utils;

import org.springframework.stereotype.Component;

import java.util.Random;

@Component
public class CodeUtils {
    //六位随机数
    public static String getSixRandom(){
        Random random = new Random();
        String fourRandom = random.nextInt(1000000) + "";
        int randLength = fourRandom.length();
        if(randLength<6){
            for(int i=1; i<=6-randLength; i++)
                fourRandom = "0" + fourRandom  ;
        }
        return fourRandom;
    }

    //阿里短信接口参数
    public static String getCode(String sz){
        //拼接参数
        String str1="**code**:";
        String str2=",**minute**:1";
        String code=str1+sz+str2;
        return code;
    }

    //生成银行卡号
    public static String getBankCard(){
        Random random = new Random();
        String str1="202107";
        String bc=str1+getSixRandom()+getSixRandom()+random.nextInt(10);

        return bc;
    }


    public static void main(String[] args) {
        //System.out.println(getCode(getSixRandom()));

        //System.out.println(getBankCard());
    }
}
